<!doctype html><html lang dir=ltr><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>【第2周笔记】Python 基本图形绘制 | Python | Hui.Ke - Blog</title><meta name=generator content="Hugo Eureka 0.9.3"><link rel=stylesheet href=https://b.hui.ke/css/eureka.min.9cec6350e37e534b0338fa9a085bf06855de3b0f2dcf857e792e5e97b07ea905d4d5513db554cbc26a9c3da622bae92d.css><script defer src=https://b.hui.ke/js/eureka.min.fa9a6bf6d7a50bb635b4cca7d2ba5cf3dfb095ae3798773f1328f7950028b48c17d06276594e1b5f244a25a6c969a705.js></script>
<link rel=preconnect href=https://fonts.googleapis.com><link rel=preconnect href=https://fonts.gstatic.com crossorigin><link rel=preload href="https://fonts.googleapis.com/css2?family=Lora:wght@400;600;700&family=Noto+Serif+SC:wght@400;600;700&display=swap" as=style onload='this.onload=null,this.rel="stylesheet"'><link rel=stylesheet href=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/styles/vs.min.css media=print onload='this.media="all",this.onload=null' crossorigin><script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/bash.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/ini.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/json.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/php.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/python.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/shell.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/sql.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/x86asm.min.js crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/xml.min.js crossorigin></script>
<link rel=stylesheet href=https://b.hui.ke/css/highlightjs.min.2958991528e43eb6fc9b8c4f2b8e052f79c4010718e1d1e888a777620e9ee63021c2c57ec7417a3108019bb8c41943e6.css media=print onload='this.media="all",this.onload=null'><script defer type=text/javascript src=https://lib.baomitu.com/font-awesome/6.1.1/js/all.min.js></script>
<link rel=stylesheet href=https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css integrity=sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ media=print onload='this.media="all",this.onload=null' crossorigin><script defer src=https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.js integrity=sha384-VQ8d8WVFw0yHhCk5E8I86oOhv48xLpnDZx5T9GogA/Y84DcCKWXDmSDfn13bzFZY crossorigin></script>
<script defer src=https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/contrib/auto-render.min.js integrity=sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR crossorigin></script>
<script>document.addEventListener("DOMContentLoaded",function(){renderMathInElement(document.body,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1},{left:"\\[",right:"\\]",display:!0}]})})</script><script defer src=https://cdn.jsdelivr.net/npm/mermaid@8.14.0/dist/mermaid.min.js integrity=sha384-atOyb0FxAgN9LyAc6PEf9BjgwLISyansgdH8/VXQH8p2o5vfrRgmGIJ2Sg22L0A0 crossorigin></script>
<link rel=icon type=image/png sizes=32x32 href=https://b.hui.ke/icon_hub7ca0b5404c6d576559b2bd22c64b0e5_2009_32x32_fill_box_center_3.png><link rel=apple-touch-icon sizes=180x180 href=https://b.hui.ke/icon_hub7ca0b5404c6d576559b2bd22c64b0e5_2009_180x180_fill_box_center_3.png><meta name=description content="  课程笔记和选择题"><script type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Docs","item":"https://b.hui.ke/docs/"},{"@type":"ListItem","position":2,"name":"Python","item":"https://b.hui.ke/docs/python/"},{"@type":"ListItem","position":3,"name":"【第2周笔记】Python 基本图形绘制","item":"https://b.hui.ke/docs/python/2/"}]}</script><script type=application/ld+json>{"@context":"https://schema.org","@type":"Article","mainEntityOfPage":{"@type":"WebPage","@id":"https://b.hui.ke/docs/python/2/"},"headline":"【第2周笔记】Python 基本图形绘制 | Python | Hui.Ke - Blog","datePublished":"2020-12-30T12:01:34+08:00","dateModified":"2022-04-06T15:13:34+08:00","wordCount":1805,"author":{"@type":"Person","name":"Hui.Ke"},"publisher":{"@type":"Person","name":"Hui.Ke","logo":{"@type":"ImageObject","url":"https://b.hui.ke/icon.png"}},"description":"\u003cp\u003e  课程笔记和选择题\u003c\/p\u003e"}</script><meta property="og:title" content="【第2周笔记】Python 基本图形绘制 | Python | Hui.Ke - Blog"><meta property="og:type" content="article"><meta property="og:image" content="https://b.hui.ke/icon.png"><meta property="og:url" content="https://b.hui.ke/docs/python/2/"><meta property="og:description" content="  课程笔记和选择题"><meta property="og:site_name" content="Hui.Ke - Blog"><meta property="article:published_time" content="2020-12-30T12:01:34+08:00"><meta property="article:modified_time" content="2022-04-06T15:13:34+08:00"><meta property="article:section" content="docs"><meta property="article:tag" content="画笔控制函数"><meta property="article:tag" content="运动控制函数"><meta property="article:tag" content="方向控制函数"><meta property="og:see_also" content="https://b.hui.ke/docs/python/20/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/10/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/19/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/9/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/18/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/8/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/17/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/7/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/16/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/6/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/15/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/5/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/14/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/4/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/13/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/3/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/12/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/11/"><meta property="og:see_also" content="https://b.hui.ke/docs/python/1/"><script>!function(e){"use strict";!function(){var i,s=window,o=document,a=e,c="".concat("https:"===o.location.protocol?"https://":"http://","sdk.51.la/js-sdk-pro.min.js"),n=o.createElement("script"),r=o.getElementsByTagName("script")[0];n.type="text/javascript",n.setAttribute("charset","UTF-8"),n.async=!0,n.src=c,n.id="LA_COLLECT",a.d=n,i=function(){s.LA.ids.push(a)},s.LA?s.LA.ids&&i():(s.LA=e,s.LA.ids=[],i()),r.parentNode.insertBefore(n,r)}()}({id:"Jgb8aUbG5e3rqhrs",ck:"Jgb8aUbG5e3rqhrs",autoTrack:!0,hashMode:!0})</script><body class="flex min-h-screen flex-col"><header class="min-h-16 pl-scrollbar bg-secondary-bg fixed z-50 flex w-full items-center shadow-sm"><div class="mx-auto w-full max-w-screen-xl"><script>let storageColorScheme=localStorage.getItem("lightDarkMode");((storageColorScheme=="Auto"||storageColorScheme==null)&&window.matchMedia("(prefers-color-scheme: dark)").matches||storageColorScheme=="Dark")&&document.getElementsByTagName("html")[0].classList.add("dark")</script><nav class="flex items-center justify-between flex-wrap px-4 py-4 md:py-0"><a href=/ class="me-6 text-primary-text text-xl font-bold">Hui.Ke - Blog</a>
<button id=navbar-btn class="md:hidden flex items-center px-3 py-2" aria-label="Open Navbar">
<i class="fas fa-bars"></i></button><div id=target class="hidden block md:flex md:grow md:justify-between md:items-center w-full md:w-auto text-primary-text z-20"><div class="md:flex md:h-16 text-sm md:grow pb-4 md:pb-0 border-b md:border-b-0"><a href=/posts/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">Posts</a>
<a href=/docs/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 selected-menu-item me-4">Docs</a>
<a href=/categories/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">Categories</a>
<a href=/series/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">Series</a>
<a href=/tags/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">Tags</a>
<a href=/love/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">Love</a>
<a href=/about/ class="block mt-4 md:inline-block md:mt-0 md:h-(16-4px) md:leading-(16-4px) box-border md:border-t-2 md:border-b-2 border-transparent me-4">About</a></div><div class=flex><div class="relative pt-4 md:pt-0"><div class="cursor-pointer hover:text-eureka" id=lightDarkMode><i class="fas fa-adjust"></i></div><div class="fixed hidden inset-0 opacity-0 h-full w-full cursor-default z-30" id=is-open></div><div class="absolute flex flex-col start-0 md:start-auto end-auto md:end-0 hidden bg-secondary-bg w-48 rounded py-2 border border-tertiary-bg cursor-pointer z-40" id=lightDarkOptions><span class="px-4 py-1 hover:text-eureka" name=Light>Light</span>
<span class="px-4 py-1 hover:text-eureka" name=Dark>Dark</span>
<span class="px-4 py-1 hover:text-eureka" name=Auto>Auto</span></div></div></div></div><div class="fixed hidden inset-0 opacity-0 h-full w-full cursor-default z-0" id=is-open-mobile></div></nav><script>let element=document.getElementById("lightDarkMode");storageColorScheme==null||storageColorScheme=="Auto"?document.addEventListener("DOMContentLoaded",()=>{window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",switchDarkMode)}):storageColorScheme=="Light"?(element.firstElementChild.classList.remove("fa-adjust"),element.firstElementChild.setAttribute("data-icon","sun"),element.firstElementChild.classList.add("fa-sun")):storageColorScheme=="Dark"&&(element.firstElementChild.classList.remove("fa-adjust"),element.firstElementChild.setAttribute("data-icon","moon"),element.firstElementChild.classList.add("fa-moon")),document.addEventListener("DOMContentLoaded",()=>{getcolorscheme(),switchBurger()})</script></div></header><main class="grow pt-16"><div class=pl-scrollbar><div class="mx-auto w-full max-w-screen-xl lg:px-4 xl:px-8"><div class=lg:pt-12><div class="flex flex-col md:flex-row bg-secondary-bg rounded"><div class="md:w-1/4 lg:w-1/5 border-e"><div class="sticky top-16 pt-6"><div id=sidebar-title class="md:hidden mx-4 px-2 pt-4 pb-2 md:border-b text-tertiary-text md:text-primary-text"><span class=font-semibold>Table of Contents</span>
<i class='fas fa-caret-right ms-1'></i></div><div id=sidebar-toc class="hidden md:block overflow-y-auto mx-6 md:mx-0 pe-6 pt-2 md:max-h-doc-sidebar bg-primary-bg md:bg-transparent"><div class="flex flex-wrap ms-4 -me-2 p-2 bg-secondary-bg md:bg-primary-bg rounded"><a class=hover:text-eureka href=https://b.hui.ke/docs/python/>Python</a></div><ul class=ps-6><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/20/>期末测验</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/10/>【第9+周笔记】全课程总结与学习展望</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/19/>【第9周程序】计算生态纵览</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/9/>【第9周笔记】计算生态纵览</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/18/>【第8周程序】程序设计方法学</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/8/>【第8周笔记】程序设计方法学</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/17/>【第7周程序】文件和数据格式化</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/7/>【第7周笔记】文件和数据格式化</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/16/>【第6周程序】组合数据类型</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/6/>【第6周笔记】组合数据类型</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/15/>【第5周程序】函数和代码复用</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/5/>【第5周笔记】函数和代码复用</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/14/>【第4周程序】程序的控制结构</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/4/>【第4周笔记】程序的控制结构</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/13/>【第3周程序】基本数据类型</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/3/>【第3周笔记】基本数据类型</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/12/>【第2周程序】Python 基本图形绘制</a></div></li><li class=py-2><div><a class="text-eureka hover:text-eureka" href=https://b.hui.ke/docs/python/2/>【第2周笔记】Python 基本图形绘制</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/11/>【第1周程序】Python 基本语法元素</a></div></li><li class=py-2><div><a class=hover:text-eureka href=https://b.hui.ke/docs/python/1/>【第1周笔记】Python 基本语法元素</a></div></li></ul></div></div></div><div class="w-full md:w-3/4 lg:w-4/5 pb-8 pt-2 md:pt-8"><div class=flex><div class="w-full lg:w-3/4 px-6"><article class=prose><h1 class=mb-4>【第2周笔记】Python 基本图形绘制</h1><div class="text-tertiary-text not-prose mt-2 flex flex-row flex-wrap items-center"><div class="me-6 my-2"><i class="fas fa-calendar me-1"></i>
<span>2020-12-30</span></div><div class="me-6 my-2"><i class="fa-solid fa-pen-to-square me-1"></i>
<span>2022-04-06</span></div><div class="me-6 my-2"><i class="fas fa-clock me-1"></i>
<span>4 min read</span></div><div class="me-6 my-2"><i class="fas fa-folder me-1"></i>
<a href=https://b.hui.ke/categories/it/ class=hover:text-eureka>IT</a></div><div class="me-6 my-2"><i class="fas fa-th-list me-1"></i>
<a href=https://b.hui.ke/series/python/ class=hover:text-eureka>Python</a></div><div class="me-6 my-2"><i class="fa-solid fa-eye me-1"></i>
<span id=busuanzi_value_page_pv><i class="fa fa-spinner fa-spin"></i></span> Hits</div></div><p>  课程笔记和选择题</p><h2 id=notes>Notes</h2><pre><code class=language-python>##PythonDraw.py
import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor(&quot;purple&quot;)
turtle.seth(-40)
for i in range(4):
    turtle.circle(40,80)
    turtle.circle(-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,180)
turtle.fd(40*2/3)
turtle.done()
</code></pre><p>turtle（海龟）库是 Python 语言的<strong>标准库</strong>之一</p><div text-align:center><img src=/images/turtle绘图窗体.webp></a></div><table><thead><tr><th style=text-align:center>英文名称</th><th style=text-align:center>RGB 整数值</th><th style=text-align:center>RGB 小数值</th><th style=text-align:center>中文名称</th></tr></thead><tbody><tr><td style=text-align:center>white</td><td style=text-align:center>255，255，255</td><td style=text-align:center>1，1，1</td><td style=text-align:center>白色</td></tr><tr><td style=text-align:center>yellow</td><td style=text-align:center>255，255，0</td><td style=text-align:center>1，1，0</td><td style=text-align:center>黄色</td></tr><tr><td style=text-align:center>megenta</td><td style=text-align:center>255，0，255</td><td style=text-align:center>1，0，1</td><td style=text-align:center>洋红</td></tr><tr><td style=text-align:center>cyan</td><td style=text-align:center>0，255，255</td><td style=text-align:center>0，1，1</td><td style=text-align:center>青色</td></tr><tr><td style=text-align:center>blue</td><td style=text-align:center>0，0，255</td><td style=text-align:center>0，0，1</td><td style=text-align:center>蓝色</td></tr><tr><td style=text-align:center>black</td><td style=text-align:center>0，0，0</td><td style=text-align:center>0，0，0</td><td style=text-align:center>黑色</td></tr><tr><td style=text-align:center>seashell</td><td style=text-align:center>255，245，238</td><td style=text-align:center>1，0.96，0.93</td><td style=text-align:center>海贝色</td></tr><tr><td style=text-align:center>gold</td><td style=text-align:center>255，215，0</td><td style=text-align:center>1，0.84，0</td><td style=text-align:center>金色</td></tr><tr><td style=text-align:center>pink</td><td style=text-align:center>255，192，203</td><td style=text-align:center>1，0.75，0.80</td><td style=text-align:center>粉红色</td></tr><tr><td style=text-align:center>brown</td><td style=text-align:center>165，42，42</td><td style=text-align:center>0.65，0.16，0.16</td><td style=text-align:center>棕色</td></tr><tr><td style=text-align:center>purple</td><td style=text-align:center>160，32，240</td><td style=text-align:center>0.63，0.13，0.94</td><td style=text-align:center>紫色</td></tr><tr><td style=text-align:center>tomato</td><td style=text-align:center>255，99，71</td><td style=text-align:center>1，0.39，0.28</td><td style=text-align:center>番茄色</td></tr></tbody></table><h3 id=turtle-画笔控制函数>turtle 画笔控制函数</h3><p>  画笔操作后一直有效，一般成对出现</p><table><thead><tr><th style=text-align:center>函数名</th><th style=text-align:center>别名</th><th style=text-align:center>含义</th></tr></thead><tbody><tr><td style=text-align:center>turtle.penup()</td><td style=text-align:center>turtle.pu()</td><td style=text-align:center>抬起画笔，海龟在飞行</td></tr><tr><td style=text-align:center>turtle.pendown()</td><td style=text-align:center>turtle.pd()</td><td style=text-align:center>落下画笔，海龟在爬行</td></tr><tr><td style=text-align:center>turtle.pensize(width)</td><td style=text-align:center>turtle.width(width)</td><td style=text-align:center>画笔宽度，海龟的腰围</td></tr><tr><td style=text-align:center>turtle.pencolor(color)</td><td style=text-align:center>-</td><td style=text-align:center>画笔颜色，海龟在涂装</td></tr></tbody></table><table><thead><tr><th style=text-align:center>pencolor(color)</th><th style=text-align:center>color 三种形式</th></tr></thead><tbody><tr><td style=text-align:center>颜色字符串</td><td style=text-align:center>turtle.pencolor(&ldquo;purple&rdquo;)</td></tr><tr><td style=text-align:center>RGB的小数值</td><td style=text-align:center>turtle.pencolor(0.63, 0.13, 0.94)</td></tr><tr><td style=text-align:center>RGB的元组值</td><td style=text-align:center>turtle.pencolor((0.63,0.13,0.94))</td></tr></tbody></table><h3 id=turtle-运动控制函数>turtle 运动控制函数</h3><p>  控制海龟行进：走直线 & 走曲线</p><p>  画笔设置后一直有效，直至下次重新设置</p><ol><li>turtle.forward(d)<ol><li>别名：turtle.fd(d)</li><li>向前行进，海龟走直线</li><li>d：行进距离，可以为负数</li></ol></li><li>turtle.circle(r, extent=None)<ol><li>根据半径 r 绘制 extent 角度的弧形</li><li>r：默认圆心在海龟左侧 r 距离的位置</li><li>extent：绘制角度，默认是 360 度整圆</li></ol></li></ol><h3 id=turtle-方向控制函数>turtle 方向控制函数</h3><p>  控制海龟面对方向：绝对角度 & 海龟角度</p><ol><li>turtle.setheading(angle)<ol><li>别名：turtle.seth(angle)</li><li>改变行进方向，海龟走角度</li><li>angle：行进方向的绝对角度</li></ol></li><li>turtle.left(angle)：海龟向左转（angle：在海龟当前行进方向上旋转的角度）</li><li>turtle.right(angle)：海龟向右转（angle：在海龟当前行进方向上旋转的角度）</li></ol><p>range(N)：产生 0 到 N-1 的整数序列，共 N 个
range(M,N)：产生 M 到 N-1 的整数序列，共 N-M 个</p><h2 id=测验-2>测验 2</h2><ol><li><p>哪个选项不能正确引用 turtle 库进而使用 setup() 函数？D</p><p>A. from turtle import*</p><p>B. import turtle as t</p><p>C. import turtle</p><p>D. import setup from turtle</p></li></ol><ul><li><p>import 只有三种使用方法，以 turtle 库为例：</p><pre><code class=language-python>import turtle
from turtle import setup   或  from turtle import *
import turtle as t  （其中t是别名，可以更换其他名称）
</code></pre></li></ul><ol start=2><li><p>关于 turtle 库，哪个选项的描述是错误的？D</p><p>A. turtle 库是一个直观有趣的图形绘制函数库</p><p>B. turtle 绘图体系以水平右侧为绝对方位的0度</p><p>C. turtle 库最早成功应用于 LOGO 编程语言</p><p>D. turtle 坐标系的原点默认在屏幕左上角</p></li></ol><ul><li>turtle 坐标系的原点默认在窗体正中间</li></ul><ol start=3><li><p>哪个选项是 turtle 绘图中角度坐标系的绝对 0 度方向？A</p><p>A. 画布正右方</p><p>B. 画布正左方</p><p>C. 画布正上方</p><p>D. 画布正下方</p></li></ol><ul><li>坐标系类似这样，角度坐标系的绝对 0 度方向是右侧</li></ul><ol start=4><li><p>哪个选项是下面代码的执行结果？B</p><pre><code class=language-python>turtle.circle(-90,90)
</code></pre><p>A. 绘制一个半径为 90 像素的整圆形</p><p>B. 绘制一个半径为 90 像素的弧形，圆心在小海龟当前行进的右侧</p><p>C. 绘制一个半径为 90 像素的弧形，圆心在小海龟当前行进的左侧</p><p>D. 绘制一个半径为 90 像素的弧形，圆心在画布正中心</p></li></ol><ul><li>circle(x, y) 表示以 x 长度为半径，y 为角度，当前方向左侧 x 处为圆心，画圆。其中 x 和 y 都可以是负数，相应取反。</li></ul><ol start=5><li><p>关于 turtle 库绘图函数，哪个选项的描述是错误的？C</p><p>A. turtle.pensize(size) 函数的作用是改变画笔的宽度为 size 像素</p><p>B. turtle.fd(distance) 函数的作用是向小海龟当前行进方向前进 distance 距离</p><p>C. turtle.circle(radius, extent=None) 函数的作用是绘制一个椭圆形，extent 参数可选</p><p>D. turtle.seth(to_angle) 函数的作用是设置小海龟当前行进方向为 to_angle，to_angle 是角度的整数值</p></li></ol><ul><li>circle() 函数不能绘制椭圆形。</li></ul><ol start=6><li><p>关于 turtle 库的画笔控制函数，哪个选项的描述是错误的？B</p><p>A. turtle.width()和turtle.pensize() 都可以用来设置画笔尺寸</p><p>B. turtle.pendown() 作用是落下画笔，并移动画笔绘制一个点</p><p>C. turtle.penup() 的别名有 turtle.pu(),turtle.up()</p><p>D. turtle.colormode() 的作用是设置画笔 RGB 颜色的表示模式</p></li></ol><ul><li>turtle.pendown() 只是放下画笔，并不绘制任何内容。</li></ul><ol start=7><li><p>哪个选项不能改变 turtle 画笔的运行方向？B</p><p>A. left()</p><p>B. bk()</p><p>C. seth()</p><p>D. right()</p></li></ol><ul><li>bk() 只能后退，但不改变方向，&ldquo;后退"不是"转向&rdquo;。</li></ul><ol start=8><li><p>哪个选项所列保留字能够实现对一组语句的循环执行？C</p><p>A. if和else</p><p>B. range()</p><p>C. for和in</p><p>D. while和def</p></li></ol><ul><li>循环相关保留字是：for..in 和 while，但 def 用于定义函数，不相关。</li></ul><ol start=9><li><p>哪个选项能够使用 turtle 库绘制一个半圆形？D</p><p>A. turtle.circle(100, 90)</p><p>B. turtle.fd(100)</p><p>C. turtle.circle(100)</p><p>D. turtle.circle(100, -180)</p></li></ol><ul><li>circle(x,y) 函数的用法，绘制半圆，第二个参数 y 是 180 的奇数倍。</li></ul><ol start=10><li><p>哪个选项对 turtle.done() 的描述是正确的？B</p><p>A. turtle.done() 用来暂停画笔绘制，用户响应后还可以继续绘制</p><p>B. turtle.done() 用来停止画笔绘制，但绘图窗体不关闭</p><p>C. turtle.done() 放在代码最后，是 turtle 绘图的必要要求，表示绘制完成</p><p>D. turtle.done() 用来隐藏 turtle 绘制画笔，一般放在代码最后</p></li></ol><ul><li>建议在每个 turtle 绘图最后增加 turtle.done()。</li></ul></article><div class=my-4><a href=https://b.hui.ke/tags/%E7%94%BB%E7%AC%94%E6%8E%A7%E5%88%B6%E5%87%BD%E6%95%B0/ class="inline-block bg-tertiary-bg text-sm rounded px-3 py-1 my-1 me-2 hover:text-eureka">#画笔控制函数</a>
<a href=https://b.hui.ke/tags/%E8%BF%90%E5%8A%A8%E6%8E%A7%E5%88%B6%E5%87%BD%E6%95%B0/ class="inline-block bg-tertiary-bg text-sm rounded px-3 py-1 my-1 me-2 hover:text-eureka">#运动控制函数</a>
<a href=https://b.hui.ke/tags/%E6%96%B9%E5%90%91%E6%8E%A7%E5%88%B6%E5%87%BD%E6%95%B0/ class="inline-block bg-tertiary-bg text-sm rounded px-3 py-1 my-1 me-2 hover:text-eureka">#方向控制函数</a></div><div class=py-2><div class="my-8 flex flex-col items-center md:flex-row"><a href=https://b.hui.ke/authors/hui.ke/ class="md:me-4 text-primary-text h-24 w-24"><img src=https://b.hui.ke/bagua.webp class="bg-primary-bg w-full rounded-full" alt=Avatar></a><div class="mt-4 w-full md:mt-0 md:w-auto"><a href=https://b.hui.ke/authors/hui.ke/ class="mb-2 block border-b pb-1 text-lg font-bold"><h3>Hui.Ke</h3></a><span class="block pb-2">❤ Cyber Security | Safety is a priority.</span>
<a href=mailto:3199731997@qq.com class=me-2><i class="fas fa-envelope"></i></a>
<a href="https://wpa.qq.com/msgrd?v=3&uin=3199731997" class=me-2><i class="fab fa-qq"></i></a>
<a href=/images/aixinxianquan.webp class=me-2><i class="fab fa-weixin"></i></a></div></div></div><div class="-mx-2 mt-4 flex flex-col border-t px-2 pt-4 md:flex-row md:justify-between"><div><span class="text-primary-text block font-bold">Previous</span>
<a href=https://b.hui.ke/docs/python/12/ class=block>【第2周程序】Python 基本图形绘制</a></div><div class="mt-4 md:mt-0 md:text-right"><span class="text-primary-text block font-bold">Next</span>
<a href=https://b.hui.ke/docs/python/11/ class=block>【第1周程序】Python 基本语法元素</a></div></div><div id=valine-comments class=mt-4></div><script defer src=https://cdn.jsdelivr.net/npm/valine@1.4.16/dist/Valine.min.js integrity=sha384-e0+DNUCJo75aOAzHQbFWYBCM9/S4f0BhRJXvEgbE3mMS85RM20MSSGStHuNdY2QK crossorigin></script>
<script>document.addEventListener("DOMContentLoaded",function(){new Valine({el:"#valine-comments",appId:"BQnVqWIiq78AdqwyhvBVAa3y-MdYXbMMI",appKey:"RKg5By312YjM8rU6WkkfK9IN",recordIP:"true",serverURLs:"https://l.hui.ke",visitor:"true"})})</script></div><div class="hidden lg:block lg:w-1/4"><div class="bg-secondary-bg
prose sticky top-16 z-10 hidden px-6 py-4 lg:block"><h3>On This Page</h3></div><div class="sticky-toc
border-s
hidden px-6 pb-6 lg:block"><nav id=TableOfContents><ul><li><a href=#notes>Notes</a><ul><li><a href=#turtle-画笔控制函数>turtle 画笔控制函数</a></li><li><a href=#turtle-运动控制函数>turtle 运动控制函数</a></li><li><a href=#turtle-方向控制函数>turtle 方向控制函数</a></li></ul></li><li><a href=#测验-2>测验 2</a></li></ul></nav></div><script>window.addEventListener("DOMContentLoaded",()=>{enableStickyToc()})</script></div></div></div></div></div><script>document.addEventListener("DOMContentLoaded",()=>{hljs.highlightAll(),changeSidebarHeight(),switchDocToc()})</script></div></div></main><footer class=pl-scrollbar><div class="mx-auto w-full max-w-screen-xl"><div class="text-center p-6 pin-b"><script async src=/js/click.js></script><div id=poem_ip></div><script type=text/javascript>jinrishici.load(function(e){tags.innerHTML=e.data.matchTags})</script><div><span id=timeDate>载入年天数...</span><span id=times>载入时分秒...</span>
<script async src=/js/duration.js></script></div><a href=https://www.foreverblog.cn/go.html target=_blank><img src=https://img.foreverblog.cn/wormhole_4_tp.gif alt style=display:inline-block;width:auto;height:32px title=穿梭虫洞-随机访问十年之约友链博客></a><p class="text-sm text-tertiary-text"><script async src=//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js></script>本站总访问量 <span id=busuanzi_value_site_pv></span> 次
&#183; 您是本站的第 <span id=busuanzi_value_site_uv></span> 个小伙伴</p><script async src=/js/tab.js></script></div></div></footer></body></html>